package com.weipai.education.controller;

import com.weipai.education.model.api.Response;
import com.weipai.education.service.UserEarningsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @Author: 曹朋飞
 * @Date: 2018/12/18 18:57
 */
@RestController
@Validated
public class UserEarningsController {
    
    @Autowired
    private UserEarningsService userEarningsService;

    /**
     * 收益列表
     * @param page
     * @param size
     * @param type
     * @param accountNumber
     * @param startTime
     * @param endTime
     * @param userId
     * @return
     */
    @RequestMapping(value = "/userEarnings/list", method = RequestMethod.GET)
    public Response list(@NotNull(message = "page不能为空") @RequestParam(value = "page") Integer page,
                         @NotNull(message = "size不能为空") @RequestParam(value = "size") Integer size,
                         @RequestParam(value = "type", required = false) String type,
                         @RequestParam(value = "accountNumber", required = false) String accountNumber,
                         @RequestParam(value = "startTime", required = false) String startTime,
                         @RequestParam(value = "endTime", required = false) String endTime){
        return userEarningsService.list(page, size, type, accountNumber, startTime, endTime);
    }

    /**
     * 平台财务报表
     * @return
     */
    @RequestMapping(value = "/userEarnings/pcList", method = RequestMethod.GET)
    public Response pcList(@NotNull(message = "page不能为空") @RequestParam(value = "page", required = false) Integer page,
                           @NotNull(message = "size不能为空") @RequestParam(value = "size", required = false) Integer size,
                           @NotBlank(message = "type不能为空") @RequestParam(value = "type") String type, 
                           @RequestParam(value = "userId", required = false) String userId){
        return userEarningsService.pcList(page, size, type, userId);
    }


    /**
     * 系统首页
     * @return
     */
    @RequestMapping(value = "/userEarnings/homePage", method = RequestMethod.GET)
    public Response homePage(@RequestParam(value = "userId") String userId){
        return userEarningsService.homePage(userId);
    }
    
    
    
    
    
    
    
}
